<template>
  <div>
    <FilterTable
      ref="materialsTable"
      :columns="maintenanceMaterialsColumns"
      :dataSource="maintenanceMaterialsList"
      :isToperInfo="false"
      :isColumnFilter="false"
      :height="400"
      :isMemoryPagination="true"
      :isSelectColumn="false"
      :onColumnsChange="columns => (this.maintenanceMaterialsColumns = columns)"
    ></FilterTable>
  </div>
</template>

<script>
import moment from 'moment';
import { getPartPayObject } from '@/api/finance/repairFinance/cancelFinance';
export default {
  name: 'Maintenancematerials',
  props: ['vehicleDetailsVin', 'list', 'resetTable'],
  data() {
    this.BaseTable = null;
    return {
      maintenanceMaterialsColumns: this.createMaintenanceMaterialsColumns(),
      maintenanceMaterialsList: []
    };
  },
  watch: {
    list(val) {
      this.insertRecords(val);
    },
    resetTable(val) {
      if (val) {
        this.maintenanceMaterialsList = [];
      }
    }
  },
  mounted() {
    this.BaseTable = this.$refs.materialsTable.$refs.pageTable;
    if (!this.resetTable) {
      this.insertRecords(this.list);
    }
  },
  created() {
    // this.dmsFunc = {dmsFuncId:35100010};
    // this.protectRepairFun(this.vehicleDetailsVin);
  },
  methods: {
    createMaintenanceMaterialsColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },

        // {
        //   title: '收费类别',
        //   dataIndex: 'MANAGE_SORT_NAME',
        //   width: 150,
        //   sorter: true,
        //   filter: true,
        //   filterType: 'input'
        //   // align:"center"
        // },
        {
          title: '收费区分',
          dataIndex: 'CHARGE_PARTITION_NAME',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '备件名称',
          dataIndex: 'PART_NAME',
          width: 150,
          showOverflowTooltip: true,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '备件销售单价',
          dataIndex: 'PART_SALES_PRICE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
          // align:"center"
        },
        {
          title: '成本价',
          dataIndex: 'PART_COST_PRICE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
          // align:"center"
        },
        {
          title: '备件数量',
          dataIndex: 'PART_QUANTITY',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
          // align:"center"
        },
        {
          title: '备件销售金额',
          dataIndex: 'PART_SALES_AMOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
          // align:"center"
        },
        {
          title: '折扣率',
          dataIndex: 'DISCOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
          // align:"center"
        },
        {
          title: '优惠金额',
          dataIndex: 'DISCOUNT_AMOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
          // align:"center"
        },
        {
          title: '实收金额',
          dataIndex: 'REAL_RECEIVE_AMOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input',
          precision: 2
          // align:"center"
        },
        {
          title: '仓库代码',
          dataIndex: 'STORAGE_CODE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '计量单位',
          dataIndex: 'UNIT_NAME',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '备件代码',
          dataIndex: 'PART_NO',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '是否委外',
          dataIndex: 'CONSIGN_EXTERIOR',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '活动编号',
          dataIndex: 'ACTIVITY_CODE',
          width: 170,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '维修项目代码',
          dataIndex: 'LABOUR_CODEF',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '车系',
          dataIndex: 'MODEL_LABOUR_NAME',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '组合代码',
          dataIndex: 'PACKAGE_CODE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '套餐代码',
          dataIndex: 'SERVICE_PACKAGE_CODE',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '不可打折',
          dataIndex: 'IS_DISCOUNT',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        },
        {
          title: '备件类别',
          dataIndex: 'PART_CATEGORY',
          width: 150,
          sorter: true,
          filter: true,
          filterType: 'input'
          // align:"center"
        }
      ];
    },
    orderListChangeHandle(val) {},
    insertRecords(list) {
      this.maintenanceMaterialsList = list;
      // this.BaseTable.EXECUTE_INSERT(list);
    }
  }
};
</script>

<style lang="less">
.custom-wrap {
  height: calc(100vh - 145px);
  // position: relative;
}
</style>
